Skip to content

Conversation

@ylecarvalho
Copy link

@ylecarvalho ylecarvalho commented Nov 19, 2025

Description

This PR improve the speed to scroll and panning when is using DateTimeCategoryAxis

Ticket

Changes

Was created the _binarySearch helper function that is used the binary search algorithm to find the index in labels when is calling the updateXValues

Because the List.contains and List.indexOf uses linear search that is On, so in large datasets is really slow. The binary search is O(log n) a lot of faster, and only requires the data to be sorted, what isn't a problem because it's a DateTime axis so the data will always be sorted.

Testing

To test you can create an example chart using DateTimeCategoryAxis, and compare the chart generate with this code with the master branch.

Before After
Screen.Recording.2025-11-19.at.14.22.23.mov
Screen.Recording.2025-11-19.at.14.29.37.mov

How I find this problem

Looking in CPU profiler in dev tools, I found that 80% of the time was spent using List.contains and List.indexOf

Screen.Recording.2025-11-19.at.15.17.08.mov

@VijayakumarMariappan VijayakumarMariappan added charts Charts component open Open labels Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

charts Charts component open Open

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants